package com.example.xposed_apk.Utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class GetPermission {
    public static List<String> getAppPermissions(Context context, String packageName) {
        try {
            // 获取目标应用的PackageInfo（包含权限信息）
            PackageManager pm = context.getPackageManager();
            PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);

            // 返回权限列表（可能为null）
            return packageInfo.requestedPermissions != null ?
                    Arrays.asList(packageInfo.requestedPermissions) :
                    Collections.<String>emptyList();
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return Collections.emptyList();
        }
    }
}